﻿// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "PaperZDCharacter.h"
#include "WarriorCharacter.generated.h"
class UInputMappingContext;
class UInputAction;
struct FInputActionValue;
UCLASS()
class MY2DGAME_API AWarriorCharacter : public APaperZDCharacter
{
	GENERATED_BODY()

public:
	AWarriorCharacter();
	virtual void BeginPlay() override;
	virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
private:
	//添加相机摇臂组件AllowPrivateAccess = "true"使私有成员在蓝图可以被访问，并且保持C++中的私有访问权限
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Component, meta = (AllowPrivateAccess = "true"))
	class USpringArmComponent* SpringArmComponent;

	//添加相机组件
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Component, meta = (AllowPrivateAccess = "true"))
	class UCameraComponent* CameraComponent;

	UPROPERTY(BlueprintReadOnly, Category = "AnimationParameters", meta = (AllowPrivateAccess = "true"))
	bool IsJumped;

	//判断是否在地面移动
	float MoveInputValue;
	
	UPROPERTY(EditAnywhere,Category="Input")
	TObjectPtr<UInputMappingContext> AuraContext;
	UPROPERTY(EditAnywhere,Category="Input")
	TObjectPtr<UInputAction> MoveAction;
	UPROPERTY(EditAnywhere,Category="Input")
	TObjectPtr<UInputAction> JumpAction;


	UFUNCTION(BlueprintPure, Category = "AnimationParameters")
	FORCEINLINE bool IsRunning() const { return IsGround() && MoveInputValue!=0;} //头文件直接调用方法，能少量提高性能

	//添加一个判断下落的方法
	UFUNCTION(BlueprintPure, Category = "AnimationParameters")
	bool IsFalling() const { return !IsGround() && GetVelocity().Z<=0.f;}

	//判断是否要落地下蹲
	UFUNCTION(BlueprintPure, Category = "AnimationParameters")
	bool IsLanding() const;
	//判断是否在地面
	bool IsGround() const;

	//设置移动值
	void SetMoveInputValue(const float InpuntValue);
	void Move(const FInputActionValue& InputActionValue);
	virtual void Jump() override;
	UFUNCTION()
    void OnCharacterLanded(const FHitResult& Hit);
};
